<#include "../../header.ftl" />
<@head title="论坛 - ${sitename}"/>
	<link media="all" href="${template_url}/style/bbs.css" rel="stylesheet">
	<script type="text/javascript" src="${template_url}/script/bbs.js" charset="utf-8"></script>
	<@nav current="论坛"/>
	<div class="container">
		<div class="grid grid-20 last">
			<#if topic?exists>
				<div class="m-crumb">
				    <ul class="f-cb">
				        <li><i>&gt;</i><a href="${base}/forums">论坛</a></li>
				        <li><i>&gt;</i><a href="${base}/forums/${topic.forum.id}">${topic.forum.name}</a></li>
				        <li><i>&gt;</i><a href="javascript:void(0);">${topic.title}</a></li>
				    </ul>
				</div>
				<div class="post_list">
					<div class="post_list_top">
						<table cellspacing="0" cellpadding="0" width="100%">
	                        <tbody>
	                            <tr>
	                                <td class="post_left split_line_l">
	                                    <p class="overView">查看：<span class="yh">${views!"0"}</span> 回复：<span class="yh">${replys!"0"}</span></p>
	                                </td>
	                                <td class="post_right split_line_r">
	                                    <div class="post_title">
	                                        <h1>${topic.title}</h1>
	                                    </div>
	                                </td>
	                            </tr>
	                        </tbody>
	                    </table>
					</div>
					
					<#if pageNo == 1>
						<div class="post_wrap" id="topic_${topic.id}">
							<table cellpadding="0" cellspacing="0">
								<tr>
									<td class="post_left split_line_l">
										<div class="user_info">
											<p class="uName"><a href="<@userSpaceUrl name=topic.author.name />" target="_blank">${topic.author.alias}</a><p>
											<div style="text-align:center;">
												<a href="<@userSpaceUrl name=topic.author.name />" target="_blank"><img src="<@avatar avatar=topic.author.smallAvatar />"/></a>
											</div>
										</div>
									</td>
									<td class="post_right split_line_r">
										<div class="post_info">
											<p class="meta"><p>
										</div>
										<div class="post_main">
											<div class="post_content">
												${topic.content}
											</div>
										</div>
									</td>
								</tr>
							</table>
						</div>
					</#if>
					
					<#if (replyPage?exists && replyPage.result?exists && replyPage.result?size > 0)>
						<#list replyPage.result as reply>
							<div class="post_wrap" id="reply_${reply.id}">
								<table cellpadding="0" cellspacing="0">
									<tr>
										<td class="post_left split_line_l">
											<div class="user_info">
												<p class="uName"><a href="<@userSpaceUrl name=reply.author.name />" target="_blank">${reply.author.alias}</a><p>
												<div style="text-align:center;">
													<a href="<@userSpaceUrl name=reply.author.name />" target="_blank"><img src="<@avatar avatar=reply.author.smallAvatar />"/></a>
												</div>
											</div>
										</td>
										<td class="post_right split_line_r">
											<div class="post_info">
												<span class="meta">发表于：${reply.createTime}</span>
												<#--计算楼层-->
												<#if pageNo == 1>
													<#if reply_index == 0><em class="floor">沙发</em></#if>
													<#if reply_index == 1><em class="floor">板凳</em></#if>
													<#if reply_index == 2><em class="floor">地板</em></#if>
													<#if reply_index == 3><em class="floor">地下室</em></#if>
												</#if>
												<#if (pageNo != 1 || reply_index > 3)>
													<#assign floor = (pageNo - 1) * pageSize + reply_index + 1/>
													<em class="floor">#${floor}楼</em>
												</#if>
												<#--计算楼层 结束-->
											</div>
											<div class="post_main">
												<div class="post_content">
													<#if reply.quote?exists>
													<blockquote><span class="">引用 <a href="<@userSpaceUrl name=reply.quoteUserName />" target="_blank">${reply.quoteUserAlias}</a>：</span><p>${reply.quoteContent}</p></blockquote>
													</#if>
													${reply.content}
												</div>
											</div>
											<div style="text-align:right;margin-right:10px;">
												<a href="javascript:showReplyThis('reply_this_floor_${reply.id}');">回复本楼</a>
												<div class="reply_this_floor" style="display: none;" id="reply_this_floor_${reply.id}">
													<form action="${base}/forums/topic/reply" method="post">
														<input type="hidden" name="topic.id" value="${topic.id}"/>
														<input type="hidden" name="quote.id" value="${reply.id}"/>
														<input type="hidden" name="quoteUser" value="${reply.author.id}"/>
														<input type="hidden" name="quoteUserName" value="${reply.author.name}"/>
														<input type="hidden" name="quoteUserAlias" value="${reply.author.alias}"/>
														<input type="hidden" name="quoteContent" value="${reply.content}"/>
													    <div class="ltxtArea">
													        <textarea name="content"
													        	onkeydown="if(this.value==this.defaultValue){this.value='';this.style.color='#000'}" 
													        	onclick="if(this.value==this.defaultValue){this.value='';this.style.color='#000'}" 
													        	onblur="if(this.value==''){this.value=this.defaultValue;this.style.color='#999'}">请输入内容</textarea>
													        <input type="submit" class="button" value="发表回复"/>
													    </div>
													    <ins style="right: 20px;"></ins>
													    <div class="clearfix"></div>
													</form>
												</div>
											</div>
										</td>
									</tr>
								</table>
							</div>
						</#list>
						<div style="text-align:right;">
							<@web.pagenavi pageEntity=replyPage baseUrl="${base}/forums/topic/${topic.id}?page=$page$" />
						</div>
					</#if>
				</div>
				
				<div class="reply_main">
					<form id="reply_form" name="reply_form" action="${base}/forums/topic/reply" method="post">
						<input type="hidden" name="topic.id" value="${topic.id}"/>
						<table cellspacing="0" cellpadding="0">
							<tr>
								<td class="reply_left">
									<div class="avatar">
										<a href="<@userSpaceUrl name=topic.author.name />" target="_blank"><img src="<@avatar avatar=topic.author.smallAvatar />"/></a>
									</div>
								</td>
								<td class="reply_right">
									<table class="reply_editor">
										<tr>
											<td class="editor"><textarea name="content" id="reply" class="reply_text"></textarea></td>
										</tr>
										<tr>
											<td class="ctrl"><input type="submit" class="button" value="发表"/></td>
										</tr>
									</table>
								</td>
							</tr>
						</table>
					</form>
				</div>
			<#else>
			404.未找到您要查看的帖子
			</#if>
		</div>
	</div>
	<script type="text/javascript">
		initReplyEditor("#reply", function(){
			$("#reply_form").submit();
		});
	</script>
<#include "../../footer.ftl" />